/******************************************************************
Copyright © LibKz 2017~2023. All rights reserved.
* @projectName   LibKz
* @author        Raiiwhen
* @email         masterraii@icloud.com
* @origin        \05_Console\01_WatchX\WatchX\ALGO
*******************************************************************/

#ifndef _ALGO_H_
#define _ALGO_H_
#include "stdint.h"


#define F_ABSMIN 1.175494351e-38F
#define F_ABSMAX 3.402823466e+38F
#define DATA_SET_SIZE 100
typedef struct{
	float a[3];
	float b[3];
	float x[3];
	float y[3];
}butterworth;

typedef struct{
	float max, min, ac, dc;
	uint16_t data_ptr;
	uint16_t set_size;
	float data[DATA_SET_SIZE];
}data_set;

uint8_t Init_set(uint16_t ch, uint16_t set_size);
float get_average(uint16_t ch);
float get_max(uint16_t ch);
float get_min(uint16_t ch);
float get_ac(uint16_t ch);
float get_dc(uint16_t ch);
uint16_t get_ptr(uint16_t ch);
uint8_t push_data(uint16_t ch, float data);
float pop_data(uint16_t ch, uint16_t ptr);
uint8_t save_dataset(uint16_t ch, char* path);
uint8_t load_dataset(uint16_t ch, char* path);

uint8_t LPF_Init(butterworth* fliter, float cut_off_freq, float sample_freq);
float LPF(butterworth* fliterh, float data);

#endif

